﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using COM.Rights.Model;
using COM.Rights.BLL;
using System.Data;

public partial class Pages_BdReviews_Default : ZMPageList<BdReviews,BdReviewsInfo>
{  
	#region 重写方法



    protected override string DefaultSortField
    {
        get
        {
            return "ReviewDate";
        }
    }


    protected override void OnBind()
    {
        base.OnBind();
        //网站
        PermUserWeb _PermUserWeb = new PermUserWeb();
        List<DBParameter> _listDBParameter = new List<DBParameter>();
        _listDBParameter.Add(new DBParameter("@TranType", "hostname"));
        _listDBParameter.Add(new DBParameter("@UID", ZASession.Account));
        IDataReader sdr = _PermUserWeb.ExecuteReader("[dbo].[mdlist_sel]", _listDBParameter, System.Data.CommandType.StoredProcedure);
        DataTable dt = new DataTable();
        dt.Load(sdr);
        ZABinder.FillList(string.Empty, ddlHostName, true, dt);

        BdProduct _BdProduct = new BdProduct();
        List<DBParameter> _listDBParameter2 = new List<DBParameter>();
        _listDBParameter2.Add(new DBParameter("@TranType", "product"));
        IDataReader sdr2 = _PermUserWeb.ExecuteReader("[dbo].[mdlist_sel]", _listDBParameter2, System.Data.CommandType.StoredProcedure);
        DataTable dt2 = new DataTable();
        dt2.Load(sdr2);
        ZABinder.FillList(string.Empty, ddlArea, true, dt2);
        //产品
        

        //ZABinder.FillList(string.Empty, ddlHostName, true, dt);

    }


    //不显示保存按纽
    protected override void InitBtnSave()
    {
        //base.InitBtnSave();
    }

    //protected override void ToolBarDeleteClick(object sender, ImageClickEventArgs e)
    //{
    //    base.ToolBarDeleteClick(sender, e);
    //}

    protected override string DefaultFilter
    {
        get
        {
            return string.Format("IsDelete = 0 AND    hostname IN ( SELECT hostname FROM permUserWeb puw(NOLOCK) WHERE puw.UID = '{0}' )", ZASession.Account);
            //return string.Format(" EXISTS( SELECT 1 FROM permUserWeb puw WHERE 1=1)");
        }
    }


	#endregion 	重写方法
    protected void btnPublish_Click(object sender, EventArgs e)
    {
        string str = "";
        foreach (string s in GetCheckedList())
        {
            str += "'" + s + "',";
        }
        str = str.Trim(',');
        if (!string.IsNullOrEmpty(str))
        {
            BdReviews _BdReviews = new BdReviews();
            BdReviewsInfo _BdReviewsInfo = new BdReviewsInfo();
            str = _BdReviewsInfo.GetPrimaryKey() + " IN (" + str + ")";
            _BdReviews.Update("IsPublish", str, true, new List<DBParameter>());
            OnGridChanged();
            
        }
    }



    protected override int PageSize
    {
        get
        {
            //return base.PageSize;
            return StringHelper.FormatBlankStringToint(txtPageSize.Text);
        }
    }

    protected void btnReply_Click(object sender, EventArgs e)
    {
        string str = "";
        foreach (string s in GetCheckedList())
        {
            str += "'" + s + "',";
        }
        str = str.Trim(',');
        if (!string.IsNullOrEmpty(str))
        {
            BdReviews _BdReviews = new BdReviews();
            BdReviewsInfo _BdReviewsInfo = new BdReviewsInfo();
            str = _BdReviewsInfo.GetPrimaryKey() + " IN (" + str + ")";
            _BdReviews.Update("reply", str, txtReply.Text, new List<DBParameter>());
            OnGridChanged();
        }
    }

}